/**
 * 订阅 /turtle1/pose话题，消息类型 turtlesim::Pose
*/
#include <ros/ros.h>
#include <turtlesim/Pose.h>
#include <string>

void TurtlePoseCallback(const turtlesim::Pose::ConstPtr& msg) {
  // log printf recv subscriber message.
  ROS_INFO("Turtle pose: x:%.6f, y:%.6f", msg->x, msg->y);
}


int main(int argc, char** argv) {
  ros::init(argc, argv, "pose_subscriber");

  ros::NodeHandle nh;

  std::string topic_name("/turtle1/pose");
  
  ros::Subscriber pose_sub =
    nh.subscribe(topic_name, 10, TurtlePoseCallback);

  while (ros::ok()) {
    ros::spinOnce(); // 循环等待回调函数
  }

  return 0;
}
